import Vue from 'vue'
import session from '@/utils/session'
import constant from '@/utils/constant'

let AutoJump = {};
AutoJump.install = function (Vue, options) {
    Vue.prototype.$autoJump = function () {
        if (!constant.AutoJumpCfg.openAutoJumpOut) {
            return
        }

        if(this.timer) {
            clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
            session.removeToken();
            const { origin } = window.location
            window.location.href = origin
            window.location.reload();
        }, constant.AutoJumpCfg.stagnateTime)
    }
}

export default AutoJump;
